home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / XPK / Source / xpkmaster / sublibs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-12  |  1.4 KB  |  61 lines

  1. #ifndef XPKMASTER_SUBLIBS_C
  2. #define XPKMASTER_SUBLIBS_C
  3.  
  4. /* Routinesheader
  5.  
  6.     Name:        sublibs.c
  7.     Main:        xpkmaster
  8.     Versionstring:    $VER: sublibs.c 1.0 (09.10.96)
  9.     Author:        SDI
  10.     Distribution:    PD
  11.     Description:    Handling of xpksublibraries
  12.  
  13.  1.0   09.10.96 : first real version
  14. */
  15.  
  16. #include <pragma/exec_lib.h>
  17. #include <exec/types.h>
  18. #include <dos/dos.h>
  19. #include "xpkmaster.h"
  20. #include "xpk_strings.h"
  21.  
  22. /************************* open sublib from ID ***************************/
  23. struct Library *opensub(struct XpkBuffer *xbuf, ULONG ID)
  24. {
  25.   UBYTE libname[] = "compressors/xpk____.library";
  26.   struct Library *XpkSubBase;
  27.  
  28.   /* Do nothing if we already have what we want */
  29.   if((xbuf->xb_SubBase) && (xbuf->xb_SubID == ID))
  30.     return xbuf->xb_SubBase;
  31.  
  32.   closesub(xbuf);
  33.  
  34.   xbuf->xb_SubID = ID;
  35.   CopyMem((STRPTR) &ID, libname+15, 4);
  36.  
  37.   if(!(XpkSubBase = OpenLibrary(libname, 0)))
  38.     xbuf->xb_Result = XPKERR_MISSINGLIB;
  39.   else if((xbuf->xb_SubInfo = XpksPackerInfo())->xi_MasterVersion > MainVersion)
  40.   {
  41.     xbuf->xb_Result = XPKERR_OLDMASTLIB;
  42.     closesub(xbuf);
  43.   }
  44.   return(xbuf->xb_SubBase = XpkSubBase);
  45. }
  46.  
  47. /*********************** close any open sub-library *********************/
  48. void closesub(struct XpkBuffer *xbuf)
  49. {
  50.   if(xbuf->xb_SubBase)
  51.   {
  52. #ifdef DEBUG
  53.     DebugRunTime("closesub: closing lib %.4s", &xbuf->xb_SubID);
  54. #endif
  55.     CloseLibrary(xbuf->xb_SubBase);
  56.     xbuf->xb_SubBase = NULL;
  57.   }
  58. }
  59.  
  60. #endif /* XPKMASTER_SUBLIBS_C */
  61.